<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
	<link rel="stylesheet" href="../static/lib/bootstrap/3.3.7/css/bootstrap.min.css" th:href="@{/lib/bootstrap/3.3.7/css/bootstrap.min.css}" />
	<style type="text/css">
	html, body, div {
		margin: 0;
		padding: 0;
	}
	</style>
	<script th:src="@{/lib/jquery/jquery-1.12.4.min.js}"></script>
	<script th:src="@{/lib/bootstrap/3.3.7/js/bootstrap.min.js}"></script>
	<!--[if lt IE 9]>
	<script src="../static/lib/html5shiv/3.7.3/html5shiv.min.js" th:src="@{/lib/html5shiv/3.7.3/html5shiv.min.js}"></script>
	<script src="../static/lib/respond/1.4.2/respond.min.js" th:src="@{/lib/respond/1.4.2/respond.min.js}"></script>
	<![endif]-->
	
</head>	
<body>
<div style="width:75%; height: 600px" th:utext="${pageoffice}" id="po_div"> </div>

<div style="width:25%; height: 600px;  position: absolute; right: 0px; top: 0px" id="sp_div"> 
<h2 style="text-align: center; color: #72afd2">合同审批</h2>
<div class="row" style="padding: 0px 20px 0px 20px;">
<div class="col-sm-12" >
<form id="audit_form">
	<input type="hidden" name="id" th:value = "${id}" />
	<hr />
	<div class="form-group" style="text-align: center; font-weight: bold;">
		<span th:if="${ct.hasFjtk}">条款审批</span>
		&nbsp;&nbsp;
		<span th:if="${jgsp}" th:text='${jgspStr}'></span>
	</div>
	<hr />
	<div class="form-group">
		<label for="isHjb">审批理由</label>
		<div>
			<p class="form-control-static" th:text="${ct.auditMemo}"></p>
		</div>
	</div>
	<hr class="next" />
	<div class="form-group" th:if="${ct.fjtkAdd}">
		<label for="isHjb">增加附加条款</label>
		<div>
			<p class="form-control-static" th:text="${ct.fjtkAdd}"></p>
		</div>
	</div>
	<hr class="next" th:if="${ct.fjtkAdd}"/>
	<div class="form-group" th:if="${ct.fjtkDel}">
		<label for="isHjb">删除附加条款</label>
		<div>
			<p class="form-control-static" th:text="${ct.fjtkDel}"></p>
		</div>
	</div>
	<hr class="next" th:if="${ct.fjtkDel}"/>
	<div class="form-group">
		<div class="radio">
			<label>
				<input type="radio" name="sp" id="sp1" value="1" checked>审批通过
			</label>
		</div>
		<div class="radio">
			<label>
				<input type="radio" name="sp" id="sp2" value="0">审批不通过
			</label>
		</div>
	</div>
	<hr class="next" />
	<div class="form-group next">
		<label for="next_audit" th:text="${next.name}">下一步</label>
		&nbsp;&nbsp;
		<select  name="nextOper" th:if="${next.opers}">
			<option th:each="oper : ${next.opers}" th:value="${oper.id}" th:text="${oper.name}"></option>
		</select>
		&nbsp;&nbsp;
		<label for="next_audit" th:if="${next.opers}">审核</label>
		<br />
		<label th:text="${next.desc}" style="text-align: center; color: #00c0ef"></label>
	</div>
	<hr />
	<div class="form-group" th:if="${syspyj}">
		<p class="form-control-static" th:text="${syspyj}"></p>
	</div>
	<hr th:if="${syspyj}"/>
	<div class="form-group">
		<label for="spyj">审批意见</label>
		<textarea class="form-control" rows="10" name="spyj"></textarea>
	</div>
	<hr />
	<button type="button" class="btn btn-primary btn-block" onclick="form_submit()">提交审批</button>
</form>
</div></div></div>

<script type="text/javascript">
function do_layout() {
	var h = $(window).height();
	var height = (h < 600 ? 600 : h - 30) + 'px';
	$("#po_div").css('height', height);
	$("#sp_div").css('height', height);
}
$(function(){
	do_layout();
	$(window).resize(function(){
		do_layout();
	});
	$(":radio").click(function(){
		if($(this).val() == 1) {
			$(".next").show();
		} else {
			$(".next").hide();
		}
	});
});

function form_submit() {
	if(!confirm("确认提交审批吗？")) return;
	
	$.post("[[@{/audit/first/submit}]]", $("#audit_form").serializeArray(), function(ret){
		if(ret.success) {
			var result = window.external.CallParentFunc("refresh('audit/first');");
			window.external.close();
		} else {
			alert(ret.message);
		}
	}, "json");
}

function fullScreen() {
    document.getElementById("page_office").FullScreen = !document.getElementById("page_office").FullScreen;
}

function office_toolbar() {
    document.getElementById("page_office").OfficeToolbars = !document.getElementById("page_office").OfficeToolbars;
}

function save() {
    document.getElementById("page_office").WebSave();
}

function close(){
	window.external.close(); 
}
</script>
</body>
</html>
